{load header}

<!--/H-->
<!-- 内容区 -->
<div id="main-content">
    <div id="top-alert" class="fixed alert alert-error" style="display: none;">
        <button class="close fixed" style="margin-top: 4px;">&times;</button>
        <div class="alert-content">这是内容</div>
    </div>
    <div id="main" class="main">

        <!-- nav --><!-- nav -->

        <div class="main-title">
            <h2>B2B任务列表</h2>
        </div>
        <div class="cf">
            <!-- 高级搜索 -->
            <!--<div class="search-form fr cf">
                <div class="sleft">
                    <div class="drop-down">
                        <span id="sch-sort-txt" class="sort-txt" data="{if $stname }{$stname}{/if}">{if $conname }{$conname}{else}所有{/if}</span>
                        <i class="arrow arrow-down"></i>
                        <ul id="sub-sch-menu" class="nav-list hidden">
                            <li><a href="javascript:;" value="0">所有</a></li>
                            <li><a href="javascript:;" value="1">发布人</a></li>
                            <li><a href="javascript:;" value="2">任务名称</a></li>
                        </ul>
                    </div>
                    <input type="text" name="key" class="search-input" value="{if $keyname }{$keyname}{/if}"
                           placeholder="请输关键词">
                    <a class="sch-btn" href="javascript:;" id="search" url=""><i class="btn-search"></i></a>
                </div>
            </div>-->
        </div>
        <div class="data-table table-striped tab-content">
            <table>
                <thead>
                <tr>
                    <th>任务名称</th>
                    <th>发布人</th>
                    <th>领取人</th>
                    <th>领取人手机号</th>
                    <th>任务需求总数</th>
                    <th>佣金</th>
                    <th>领取时间</th>
                    <th>结束数量</th>
                    <th>审核状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <!--{loop $list $val}-->
                <tr>
                    <td>{$val['title']}</td>
                    <td>{$val['username']}</td>
                    <td>{$val['receiptor']}</td>
                    <td>{$val['mobile']}</td>
                    <td>{$val['sub_num']}</td>
                    <td>{$val['commission']}</td>
                    <td>{$val['add_time']}</td>
                    <td>
                        {if $val['apply_end']==1 && $val['is_end']==0}
                        <input type="number" name="subnum" value="{$val['subnum']}" id="subnum_{$val['sid']}" onkeyup="limitInput(this);" style="width: 35px;text-align: center;float: left;"/>
                        &nbsp;&nbsp;&nbsp;&nbsp;
                        <button onclick="editNum({$val['sid']},{$val['tid']});" style="float: left;margin-left: 10px;">修改</button>
                        <div id="editSta_{$val['sid']}" style="float: left;width: 100px;margin-left: 10px;"></div>
                        {else}
                            {if $val['is_end']==1}
                                {$val['end_num']}
                            {else}
                                *
                            {/if}
                        {/if}
                    </td>
                    <td>{$val['status_val']}</td>

                    <td>
                        {if $val['qualification']==0}
                        <a href="{eval echo site_url('taskplat/ajax_judge_subtask').'?sid='.$val['sid'].'&qualification=1'}" class="confirm ajax-get">审核通过</a>
                        <a href="{eval echo site_url('taskplat/ajax_judge_subtask').'?sid='.$val['sid'].'&qualification=2'}" class="confirm ajax-get">审核不通过</a>
                        {/if}
                    </td>

                </tr>
                <!--{/loop}-->
                </tbody>
            </table>
            <!-- 分页 -->
            <div class="page">
                <div>
                    {$showpage}
                    <span class="rows">共 {$Total} 条记录</span>
                    <!--
                    <span class="rows" >金额总计 <font color="#F90">{$T_total['total']}</font> 元</span>
        <a target ="_blank;" href="{eval echo site_url('borrow/index_to_excel')}?{eval echo $_SERVER['QUERY_STRING'];}" >导出结果</a>
                    -->

                </div>
            </div>
        </div>

    </div>
</div>
<link href="{eval echo base_url()}static/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<link href="{eval echo base_url()}static/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript"
        src="{eval echo base_url()}static/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript"
        src="{eval echo base_url()}static/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"
        charset="UTF-8"></script>
<script type="text/javascript">
    function limitInput(obj) {
        obj.value=obj.value.replace(/\D/g,'');
        if(obj.value>100){
            obj.value = 100;
            obj.setAttribute("title","最大100");
        }
    }
    function editNum(sid,tid) {

        var sub_num = $("#subnum_"+sid).val();
        $.ajax({
            url: "{eval echo site_url('taskplat/ajax_update_task_num')}",
            type: "post",
            dataType: "json",
            data: {sid:sid,tid:tid,sub_num:sub_num},
            success: function(res) {
                if(res.status==1){
                    $("#editSta_"+sid).html("<font color='#8fbc8f'>"+res.info+"</font>");
                }else{
                    $("#editSta_"+sid).html("<font color='#dc143c'>"+res.info+"</font>");
                }
                setTimeout(function () {
                    location.reload();
                }, 2000);
            }
        });
    }

    $(function () {
        //搜索功能
        $("#search").click(function () {
            var url = $(this).attr('url');
            var status = $("#sch-sort-txt").attr("data");
            var query = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            query = query.replace(/^&/g, '');
            if (status != '') {
                query += '&st=' + status;
            }
            if (url.indexOf('?') > 0) {
                url += '&' + query;
            } else {
                url += '?' + query;
            }
            window.location.href = url;
        });

        /* 状态搜索子菜单 */
        $(".search-form").find(".drop-down").hover(function () {
            $("#sub-sch-menu").removeClass("hidden");
        }, function () {
            $("#sub-sch-menu").addClass("hidden");
        });
        $("#sub-sch-menu li").find("a").each(function () {
            $(this).click(function () {
                var text = $(this).text();
                $("#sch-sort-txt").text(text).attr("data", $(this).attr("value"));
                $("#sub-sch-menu").addClass("hidden");
            })
        });

        //回车自动提交
        $('.search-form').find('input').keyup(function (event) {
            if (event.keyCode === 13) {
                $("#search").click();
            }
        });

        $('#time-start').datetimepicker({
            format: 'yyyy-mm-dd',
            language: "zh-CN",
            minView: 2,
            autoclose: true
        });

        $('#datetimepicker').datetimepicker({
            format: 'yyyy-mm-dd',
            language: "zh-CN",
            minView: 2,
            autoclose: true,
            pickerPosition: 'bottom-left'
        })

    })
</script>
<!--F-->{load footer}